package com.clickpaas.workinghours.thread;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

import java.util.concurrent.Callable;

@Slf4j
public class CastListCopyCallable implements Callable {
    private Object obj;
    private Class clazz;
    private Class reclazz;

    public CastListCopyCallable(Object obj, Class clazz, Class reclazz){
        this.obj = obj;
        this.clazz = clazz;
        this.reclazz = reclazz;
    }

    @Override
    public Object call() throws Exception {
        Object entity = reclazz.newInstance();
        BeanUtils.copyProperties(clazz.cast(obj),entity);
        return entity;
    }
}
